app.controller('SystemController',function ($scope,$controller,uploadService,SystemService){
    $controller('baseController',{$scope:$scope});//继承

    $scope.entity = {
        model:[]
    }

    $scope.addTableRow = function(){
        $scope.entity.model.push({});
    }

    $scope.deleteTableRow = function(index){
        $scope.entity.model.splice(index,1);
    }

    $scope.uploadFile = function () {
        uploadService.uploadFile().success(function (response) {
            if (response.success) {//如果上传成功，取出url
                $scope.entity.pic = response.message;//设置文件地址

            } else {
                alert(response.message);
            }
        }).error(function () {
            alert("上传发生错误");
        });
    };

    $scope.save=function () {
        var serviceObject=SystemService.add;

        if($scope.entity.id!=null){
            serviceObject=SystemService.update;
        }

        serviceObject($scope.entity).success(function (resp) {
            if(resp.success){
                location.href='xitong.html';
            }else {
                alert(resp.message);
            }
        })
    }


    $scope.findAll=function(){
        SystemService.findAll().success(
            function(response){
                $scope.list=response;
                console.log($scope.list)
            }
        );
    }

})